/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package supportlearning.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Khin
 */
@Entity
@Table(name = "Assignment", catalog = "SupportLearningDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Assignment.findAll", query = "SELECT a FROM Assignment a"),
    @NamedQuery(name = "Assignment.findByAsmId", query = "SELECT a FROM Assignment a WHERE a.asmId = :asmId"),
    @NamedQuery(name = "Assignment.findByAsmName", query = "SELECT a FROM Assignment a WHERE a.asmName = :asmName"),
    @NamedQuery(name = "Assignment.findByAsmFile", query = "SELECT a FROM Assignment a WHERE a.asmFile = :asmFile"),
    @NamedQuery(name = "Assignment.findByStartDate", query = "SELECT a FROM Assignment a WHERE a.startDate = :startDate"),
    @NamedQuery(name = "Assignment.findByEndDate", query = "SELECT a FROM Assignment a WHERE a.endDate = :endDate"),
    @NamedQuery(name = "Assignment.findByDescription", query = "SELECT a FROM Assignment a WHERE a.description = :description")})
public class Assignment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "AsmId", nullable = false)
    private Integer asmId;
    @Basic(optional = false)
    @Column(name = "AsmName", nullable = false, length = 50)
    private String asmName;
    @Basic(optional = false)
    @Column(name = "AsmFile", nullable = false, length = 200)
    private String asmFile;
    @Basic(optional = false)
    @Column(name = "StartDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    @Basic(optional = false)
    @Column(name = "EndDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    @Column(name = "Description", length = 200)
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assignment")
    private List<StudentResult> studentResultList;
    @JoinColumn(name = "SubId", referencedColumnName = "SubId", nullable = false)
    @ManyToOne(optional = false)
    private Subject subId;
    @JoinColumn(name = "StaffId", referencedColumnName = "StaffId", nullable = false)
    @ManyToOne(optional = false)
    private StaffProfile staffId;

    public Assignment() {
    }

    public Assignment(Integer asmId) {
        this.asmId = asmId;
    }

    public Assignment(Integer asmId, String asmName, String asmFile, Date startDate, Date endDate) {
        this.asmId = asmId;
        this.asmName = asmName;
        this.asmFile = asmFile;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public Integer getAsmId() {
        return asmId;
    }

    public void setAsmId(Integer asmId) {
        this.asmId = asmId;
    }

    public String getAsmName() {
        return asmName;
    }

    public void setAsmName(String asmName) {
        this.asmName = asmName;
    }

    public String getAsmFile() {
        return asmFile;
    }

    public void setAsmFile(String asmFile) {
        this.asmFile = asmFile;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<StudentResult> getStudentResultList() {
        return studentResultList;
    }

    public void setStudentResultList(List<StudentResult> studentResultList) {
        this.studentResultList = studentResultList;
    }

    public Subject getSubId() {
        return subId;
    }

    public void setSubId(Subject subId) {
        this.subId = subId;
    }

    public StaffProfile getStaffId() {
        return staffId;
    }

    public void setStaffId(StaffProfile staffId) {
        this.staffId = staffId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (asmId != null ? asmId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Assignment)) {
            return false;
        }
        Assignment other = (Assignment) object;
        if ((this.asmId == null && other.asmId != null) || (this.asmId != null && !this.asmId.equals(other.asmId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entity.Assignment[ asmId=" + asmId + " ]";
    }
    
}
